<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    const roleList = [{
        id: 1,
        name: '老板'
    }, {
        id: 2,
        name: '经理'
    }, {
        id: 3,
        name: '运营总监'
    }, {
        id: 4,
        name: 'CEO'
    }, {
        id: 5,
        name: '销售'
    }, {
        id: 6,
        name: '实施'
    }, {
        id: 7,
        name: '程序员'
    }, {
        id: 8,
        name: 'UI工程师'
    }, {
        id: 9,
        name: '产品经理'
    }];

    // 用户已选择的数组
    const selectedRoleList = [{
        id: 2,
        name: '经理'
    }, {
        id: 3,
        name: '运营总监'
    }, {
        id: 6,
        name: '实施'
    }, {
        id: 7,
        name: '程序员'
    }, {
        id: 9,
        name: '产品经理'
    }];

</script>
<script>
    // 要求获取用户未选中的角色列表，
    var arr = roleList.filter(item => {
        return !selectedRoleList.some(itemSelected => {
            return itemSelected.id == item.id
        })
    })
    console.log(arr);
    // 和用户已选择的角色的id数组。
    selectedRoleList.map(item => { return item.id })

    selectedRoleList.map(item => item.id)
</script>

</html>